//
//  WYFoodController.m
//  Boss
//
//  Created by admin on 2018/6/25.
//  Copyright © 2018年 admin. All rights reserved.
//

#import "WYFoodController.h"
#import "SDCycleScrollView.h"
#import "WYFoodCell.h"
@interface WYFoodController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong) SDCycleScrollView *advView;
@property (nonatomic,strong)UITableView *tableView;
@end

@implementation WYFoodController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    // Do any additional setup after loading the view.
}
-(void)setupUI
{
    self.navigationItem.title = @"餐饮美食";
    [self.view addSubview:self.tableView];
    self.tableView.contentInset = UIEdgeInsetsMake(IMAGE_HEIGHT, 0, 0, 0);
    [self.tableView addSubview:self.advView];
    NSArray *array = @[@"http://imgsrc.baidu.com/imgad/pic/item/cb8065380cd79123499f23a0a7345982b3b780e3.jpg",@"http://img18.3lian.com/d/file/201709/19/b35e13d1416c91c7a15621ec41f7fea1.jpg",@"http://d.hiphotos.baidu.com/zhidao/pic/item/ae51f3deb48f8c541fe2f2b73c292df5e0fe7f70.jpg"];
    [self.advView setImageURLStringsGroup:array];
    self.tableView.estimatedRowHeight = 150;
    [self.tableView registerNib:[UINib nibWithNibName:@"WYFoodCell" bundle:nil] forCellReuseIdentifier:@"WYFoodCell"];
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    WYFoodCell *cell = [tableView dequeueReusableCellWithIdentifier:@"WYFoodCell" forIndexPath:indexPath];
    if (!cell) {
        cell = [[NSBundle mainBundle]loadNibNamed:@"WYFoodCell" owner:nil options:nil].firstObject;
    }
    return cell;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (UITableView *)tableView
{
    if (_tableView == nil) {
        CGRect frame = CGRectMake(0, self.navHeight, kScreenWidth, kScreenHeight-44);
        _tableView = [[UITableView alloc] initWithFrame:frame
                                                  style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
    }
    return _tableView;
}
- (SDCycleScrollView *)advView
{
    if (_advView == nil) {
        _advView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, -IMAGE_HEIGHT, kScreenWidth, IMAGE_HEIGHT) imageNamesGroup:nil];
        _advView.pageDotColor = [UIColor grayColor];
        _advView.autoScrollTimeInterval = 2;
        _advView.currentPageDotColor = [UIColor whiteColor];
        _advView.bannerImageViewContentMode = UIViewContentModeScaleAspectFill;
        _advView.backgroundColor = [UIColor redColor];
    }
    return _advView;
}

@end
